<div class="next_head">
    <div class="wrap">申请提现</div>
</div>
<div class="bank_nav">
    <div class="bank_add wrap">
        <h2>添加提现银行卡</h2>
        <form class="form-horizontal" id="cashbank" role="form">
            <div class="form-group">
                <label for="inputEmail3" class="col-sm-3 control-label ft-l">
                    <div class="cardtit">银行卡:</div>
                </label>
                    
                        <?php if($cards):?>
                        <div class="col-sm-4  ft-l" >
                          <div class="card_nav">
                              <img src="<?php echo image_path('bank/'.$cards->getBankCode().'.gif')?>" id="bankimg" />
                              <div class="addcard">尾号：<?php echo $last_num;?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span data-toggle="modal" data-target="#withdrawcashmodel">编辑</span></div>
                          </div>
                        </div>
                        <?php else:?>
                        <div class="col-sm-4  ft-l" data-toggle="modal" data-target="#withdrawcashmodel">
                          <div class="card_nav" id="add_bank">
                              <strong>+</strong>
                              <div class="addcard">添加银行卡</div>
                          </div>
                        </div>
                        <?php endif;?>
                    

            </div>
        </form>
        <hr />
        <h2>填写提现金额</h2>
        <form class="form-horizontal" role="form" id="withdrawcashForm" method="POST" action="<?php echo url_for('account/withdrawcash');?>">
            <div class="alert alert-danger" id="error" style="display: none;"> </div>
            <div class="form-group">
                <input type="hidden" value="<?php echo $user_cards[0]->getId(); ?>" name="user_bank_id" id="BankCardId"/>
                <input type="hidden" name="fee" id="fee" value="0"/>
                <input type="hidden" name="money" id="money" value="<?php echo $user->getRemainingMoney(); ?>"/>
                <label for="WithDrawAmount" class="col-sm-3 control-label ft-l">提现金额</label>
                <div class="col-sm-3  ft-l">
                    <input id="current_money" type="text" class="form-control ft-l" id="WithDrawAmount" onkeyup="value=value.replace(/[^\d.]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))" name="current_money">
                </div>
                <p class="form-control-static">元</p>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label  ft-l">提款方式</label>
                <div class="col-sm-9  ft-l">
                    <p class="form-control-static">1~3个工作日内到账</p>
                </div>
            </div>
            <div class="form-group" style="margin-bottom: 8px;">
                <label class="col-sm-3 control-label  ft-l">手续费</label>
                <div class="col-sm-9  ft-l shouxu">
                    <p class="form-control-static" id="Amountsx">¥0.00</p>
                </div>
                <span class="icon20_b icon_qust" id="shouxu"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label  ft-l">可用余额</label>
                <div class="col-sm-9  ft-l shouxu">
                    <p class="form-control-static"><?php echo sfConfig::get('app_symbol').number_format($user->getRemainingMoney(),2);?></p>
                </div>
                <span class="icon20_b icon_qust" id="keyong"></span>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-9">
                    <button type="button" class="btn btn-primary" id="BtnSummit">确 定 </button>
                </div>
            </div>
        </form>
       
        <div class="panel panel-lend" id="tbjl">
            <div class="panel-body">
                <table class="table table-hover lender">
                    <thead>
                        <tr>
                            <th width="300">提现金额</th>
                            <th width="300">提现时间</th>
                            <th width="">状态</th>
                            <th width="">预计到账时间</th>
                        </tr>
                    </thead>
                    <tbody>
                       <?php if(!empty($drawlist)): ?>
                       <?php foreach($drawlist as $one): ?>
                            <tr>
                                <td><?php echo number_format($one->getCurrentMoney(),2); ?></td>
                                <td><?php echo $one->getDateTimeObject('created_at')->format('Y-m-d H:m:s'); ?></td>
                                <td><?php echo UserAccountCashRecord::$status[$one->status]; ?></td>
                                <td>1-3个工作日</td>
                            </tr>
                         <?php endforeach;?>
                         <?php endif;?>  
                    </tbody>
                </table>
            </div>
        </div>
        
        <h4>温馨提示</h4>
        <dl>
            <dd>•&nbsp;&nbsp;&nbsp;&nbsp;请确保您输入的提现金额，以及银行帐号信息准确无误。</dd>
            <dd>•&nbsp;&nbsp;&nbsp;&nbsp;如果您填写的提现信息不正确可能会导致提现失败，由此产生的提现费用将不予返还。</dd>
            <dd>•&nbsp;&nbsp;&nbsp;&nbsp;在双休日和法定节假日期间，用户可以申请提现，微美贷会在下一个工作日进行处理。由此造成的不便，请多多谅解！</dd>
            <dd>•&nbsp;&nbsp;&nbsp;&nbsp;平台禁止洗钱、信用卡套现、虚假交易等行为，一经发现并确认，将终止该账户的使用。</dd>
        </dl>
    </div>
</div>
<script type="text/javascript" src="./js/sco/sco.message.js"></script>
<script type="text/javascript">
    $("#10003").addClass('on');

    $("#BtnSummit").on('click', function () {
      
        var BankCardIdpar;
        if ($("#BankCardId").val() == "") {
            $("#error").html("请添加银行卡！").show();
            return false;
        } else {
            BankCardIdpar = $("#BankCardId").val();
        }
        var current_money = "";
        if ($("#current_money").val() == "") {
             $("#error").html("提现金额不能为空").show();
             return false;
        } else {
            current_money = $("#current_money").val();
        }
        var fee = $("#fee").val();
      
        var money=$("#money").val();
        
        if(parseInt(current_money) > parseInt(money)){
          $("#error").html("提现金额不能大于可用余额").show();
          return false;
        }
        
       // var m=parseInt(current_money)+parseInt(fee);
        if(parseInt(fee) > parseInt(current_money)){
          $("#error").html("您的提现金额不能小于手续费").show();
          return false;
        }
        
        $("#withdrawcashForm").submit();
        
    });
    var options = {
        selector: false,
        html: true,
        content: "提现金额≤5万，收取5元；<br/>大于5万，≤10万，收取10元，以此类推。",
        placement: 'right',
        trigger: 'hover'
    };
    $("#shouxu").popover(options);
    $("#current_money").on('keyup', function () {
        $("#Amountsx").text("¥" + Math.ceil(((Number($(this).val()) / 50000 * 10000) / 10000)) * 5);
        $("#fee").val(Math.ceil(((Number($(this).val()) / 50000 * 10000) / 10000)) * 5);
    });
    var optionss = {
        selector: false,
        html: true,
        content: "提现金额不得大于（可用金额 - 手续费）",
        placement: 'right',
        trigger: 'hover'
    };
    $("#keyong").popover(optionss);
    
</script>
<div class="modal fade" id="withdrawcashmodel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title" id="myModalLabel">                    添加银行卡</h4>
            </div>
            <div class="modal-body">
                <iframe src="<?php echo url_for('account/bindcard');?>" width="100%" style="border: none; height: 580px;"></iframe>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>


